package bit.client;

import java.io.IOException;

import bit.client.view.RootLayoutController;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

public class MainApp extends Application {
	Stage primaryStage;
	private double xoffset = 0;
	private double yoffset = 0;
	@Override
	public void start(Stage primaryStage) {
		try {
			Parent root=FXMLLoader.load(getClass().getResource("view/RootLayout.fxml"));
			root.setOnMousePressed(new EventHandler<MouseEvent> (){
				@Override
				public void handle(MouseEvent event) {
					xoffset = event.getSceneX();
					yoffset = event.getSceneY();
				}
			});
			root.setOnMouseDragged(new EventHandler<MouseEvent>() {
			    @Override
			    public void handle(MouseEvent event) {
			    	primaryStage.setX(event.getScreenX() - xoffset);
			    	primaryStage.setY(event.getScreenY() - yoffset);
			    }
			});
			Scene scene = new Scene(root);
			scene.setFill(javafx.scene.paint.Color.TRANSPARENT);
			primaryStage.initStyle(StageStyle.TRANSPARENT);
			primaryStage.setScene(scene);
			primaryStage.show();
		} catch (IOException e) {
			e.printStackTrace();
		}
			    
	}
	
	public static void main(String[] args) {
		launch(args);
	}
}
